

class Person:
 #--------1-------------
 #直接定义
    # #attribute;
    # name = 'William'
    # age = 45
    # height = 183

#--------2-------------
#原始定义init
    # def __init__(self):
    #     self.name = 'Alice'

#--------3-----------
#在init方法里注入需要输入的函数
    def __init__(self,name):
        self.name = name

    #method
    def sayhi(self):
        print ('Hi,my name is ' + self.name)

#-------1\2---------------
# #create an Object
# person1 = Person()
# #call the method
# person1.sayhi()


#-------3------------
person1 = Person("Peter")
person1.sayhi()

